<?php
include_once 'social/fb/src/facebook.php';
/**
         * make instance of Facebook SDK class and pass App id, and app secret
         */
        $facebook = new Facebook(array(
                    'appId' => '267372193374004',
                    'secret' => '168428426dffcbb971bce2b2ad28b31f',
                    'cookie' => true, // enable optional cookie support
                ));
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>mobiTicketz.com::Get Social</title>
<meta charset="iso-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="styles/layout.css" type="text/css">
<script src="scripts/jquery-1.8.2.min.js"></script>
<script src="scripts/jquery-browsercheck.js"></script>
<script src="scripts/jquery-defaultvalue.js"></script>
<script src="scripts/general.js"></script>
<script src="scripts/ajax.js"></script>
<!--[if lt IE 9]>
<link rel="stylesheet" href="styles/ie.css" type="text/css">
<script src="scripts/ie/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper row0">
  <div id="topbar" class="clear">
    <form action="search.php" method="post">
      <fieldset>
        <legend>Search:</legend>
        <input type="text" value="Search Our Website&hellip;" name="search" onFocus="this.value=(this.value=='Search Our Website&hellip;')? '' : this.value ;">
        <input type="submit" id="sf_submit" value="Search">
      </fieldset>
    </form>
    <ul>
      <li><a href="#">Sign Up</a></li>
      <li><a href="http://mobiticketz.com/mticket/Dashboard">Login</a></li>
      <li><a href="#">RSS Feeds</a></li>
    </ul>
  </div>
</div>
<div class="wrapper row1">
  <header id="header" class="clear">
    <hgroup>
      <h1><a href="#">mobi<span>Tick</span>e<span>tz</span></a></h1>
      <h2>ticketing made simple</h2>
    </hgroup>
    <nav>
      <ul class="clear">
         <li><a href="index.php">Home</a><span></span></li>
        <li><a href="organisers.php">Organisers</a><span></span></li>
        <li  class="active"><a href="events.php">Events</a><span></span>
		 <ul>
            <li><a href="justin.php">Just In Events</a></li>
            <li><a href="upcoming.php">Upcoming Events</a></li>
          </ul>
		</li>
        <li><a href="register.php">Register</a><span></span></li>
		<li><a href="categories.php">Categories</a><span></span></li>
        <li><a href="contactus.html">Contact Us</a><span></span></li>
      </ul>
    </nav>
  </header>
</div>
<!-- content -->
<div class="wrapper row3">
  <div id="container" class="clear">
    <div id="content">
    <?php
          

    
    ?>
        <p>Receipt Link <a href="<?php echo $_GET['url']; ?>">Download</a></p>
        <p>Get Social</p>
        <?php
 
        /**
         * Get session of the logged in user
         */
        //$session = $facebook->getSession();
		//$session = $facebook->getSharedSessionCookieName();
        /**
         * Access token is your pass to the Facebook API
         */
        //$access_token = $session['access_token'];
        $access_token = $facebook->getAccessToken();
		//echo $access_token;
        /**
         * Your Message is updated, you need to post this along with the access token
         */
        $data = array(
            //'access_token' => $access_token,
            'message' => 'Hello, I just bought a ticket for '.$_GET['name'].'. Join me by buying a ticket in the link below.',
            'link' => 'http://mobiticketz.com/web/event.php?id='.$_GET['id']
        );
        $user = $facebook->getUser();
        if ($user) {
         //echo " Valid user";
            /**
             * Lets post the status
             */
			// echo $user;
			try
			{
			 $return = $facebook->api('/me/feed', 'post', $data);
			}catch(FacebookApiException $e)
			{
				echo $e->getMessage();
			}
			 //echo 'https://graph.facebook.com/' . $user . '/feed';
           // $return = json_decode(make_post('https://graph.facebook.com/' . $user->id . '/feed', $data));
             //echo $return;
            if ($return)
                echo "<p>Activity shared successfully</p>";

            if (isset($return->error))
                echo "<p>".$return->error->message."</p>";
        } else {
            /**
             * else if the session is not there, ask user to Login
             */
        ?>
            <div id="fb-root"></div>
            <!-- Include the Facebook JS -->
            <script src="http://connect.facebook.net/en_US/all.js"></script>

            <script>
                //init function to start the facebook JS API
                FB.init({
                    appId:'267372193374004', cookie:true,
                    status:true, xfbml:true
                });
                //Login function, shows the login popup and redirects to the same page
                function fbLogin (id,url,name) {
                    FB.login(function(response) {
                        if (response.session) {
                            if (response.perms) {
                                window.location = "getsocial.php?id="+id+"&url="+url+"&name="+name;
                            } else {
                                alert('No Permission Granted !!');
                            }
                        } else {
                            // user is not logged in
                        }
                        // we ask for publish permissions
                    }, {perms:'publish_stream'});
                }

            </script>
            <!-- simple HTML login button -->
            <p>You have to login to share this.</p> Please Login <a href="javascript:fbLogin(<?php echo $_GET['id']; ?>,'<?php echo $_GET['url']; ?>','<?php echo $_GET['name']; ?>');">here</a>
        <?php
        }
        ?>
    </div>
    <!-- / content body -->
  </div>
</div>
<!-- Footer -->
<div class="wrapper row4">
  <div id="footer" class="clear">
    <!-- Section One -->
    <section class="one_third first">
       <div class="newsletter">
        <h2 class="title">Subscribe</h2>
        <p>Please subscribe to get the latest events updates</p>
       <form method="post" action="process/subscribe.php">
          <fieldset>
            <legend>Subscribe:</legend>
            <label for="nl_email">Email:</label>
            <input type="text" name="emailAddr" id="emailAddr" value="">
            <input type="submit" id="nl_submit" value="submit">
          </fieldset>
        </form>
      </div>
      <div class="social">
       <h2 class="title">Stay Social</h2>
        <ul class="clear">
         <li><a href="https://www.facebook.com/mobiticketzdotcom"><img src="images/facebook.png" alt=""></a> Facebook</li>
          <li><a href="https://www.twitter.com/mobiticketz"><img src="images/twitter.png" alt=""></a> Twitter</li>
          <li><a href="#"><img src="images/plus.gif" alt=""></a> Google Plus</li>
        </ul>
      </div>
    </section>
    <!-- Section Two -->
    <section class="one_third">
      <div class="social">
      <h2 class="title">Download Our Apps</h2>
        <ul class="clear">
          <li><a href="#"><img src="images/android.png" width="50" height="50" alt=""></a> Android</li>
          <li><a href="#"><img src="images/bb.png" width="50" height="50" alt=""></a> Blackberry</li>
          <li><a href="#"><img src="images/ios.png" width="50" height="50" alt=""></a> IOS</li>

        </ul>

      </div>
    </section>
    <!-- / Section -->
  </div>
</div>
<!-- Copyright -->
<div class="wrapper row5">
 <footer id="copyright" class="clear">
    <p class="fl_left">Copyright &copy; 2012 - All Rights Reserved - <a href="#">mobiTicketz.com</a></p>
    <p class="fl_right">Website by <a target="_blank" href="http://www.os-templates.com/" title="Free Website Templates">Logiclab</a></p>
  </footer>
</div>
<script>
$(document).ready(function () {
    $("#emailAddr").defaultvalue("Enter Your Email Here");
});
</script>
</body>
</html>